// *******************************************************************************************************
// # サイト共通スクリプト
// *******************************************************************************************************

var uaInfo = (function() {
	var that = {};
	var userAgent  = window.navigator.userAgent;
	var appVersion = window.navigator.appVersion.toLowerCase();
	that.isIe = false;
	that.ieVr = 10;
	that.oldIe = false;
	that.fixedSupport = true;
	that.terminal = '';
	that.interface = 'mouse';

	if (userAgent.indexOf('iPhone') > 0 || userAgent.indexOf('iPod') > 0) {
		that.interface = 'touch';
		that.terminal = 'iPhone';
		if (userAgent.indexOf('OS 4') != -1 || userAgent.indexOf('OS 3') != -1 || userAgent.indexOf('OS 2') != -1) {
			that.fixedSupport = false;
		}
	} else if (userAgent.indexOf('iPad') > 0) {
		that.interface = 'touch';
		that.terminal = 'iPad';
		if (userAgent.indexOf('OS 4') != -1 || userAgent.indexOf('OS 3') != -1 || userAgent.indexOf('OS 2') != -1) {
			that.fixedSupport = false;
		}
	} else if (userAgent.indexOf('Android') > 0) {
		that.interface = 'touch';
		if(userAgent.indexOf('Mobile') > 0) {
			that.terminal = "androidMob";
		} else {
			that.terminal = "androidTab";
		};
		if (userAgent.indexOf('Android 3.') != -1 || userAgent.indexOf('Android 2.') != -1 || userAgent.indexOf('Android 1.') != -1) {
			that.fixedSupport = false;
		}
	};

	if (userAgent.toLowerCase().indexOf('msie') != -1) {
		if (appVersion.indexOf('msie 6.') != -1) {
			that.ieVr = 6;
			that.fixedSupport = false;
			that.oldIe = true;
		} else if (appVersion.indexOf('msie 7.') != -1) {
			that.ieVr = 7;
			that.oldIe = true;
		} else if (appVersion.indexOf('msie 8.') != -1) {
			that.ieVr = 8;
			that.oldIe = true;
		} else if (appVersion.indexOf('msie 9.') != -1) {
			that.ieVr = 9;
		};
		that.isIe = true;
	}
	return that;
}());

$(function(){
	/** scroll */
	$('a.scroll').on('click', function(e){
		e.preventDefault();
		var ta = $(this).attr('href');
		var pt = $(ta).offset().top;
		if (ta != '#pagetop') {
			pt -= $('#headerWrapper').height();
		};
		var wh = $(window).height();
		var ch = $('#containerWrapper').height();
		if (pt + wh > ch) {
			pt = ch - wh;
		};
		$('html,body').stop().animate({ scrollTop:pt }, 600, 'easeOutQuart');
	});
});